package com.ch06.service;

import com.ch06.mapper.UserMapper;
import com.ch06.pojo.User;
import com.ch06.utils.MyBatisSqlSessionFactory;
import org.apache.ibatis.session.SqlSession;

/**
 * @ClassName UserService
 * @Description TODO
 * @Author Kx
 * @Date 2025/4/24 16:22
 * @Version 1.0
 */
public class UserService {
    /**
     * @author: kx
     * @date: 2025/4/24 16:22
     * @param id : 学生编号
     * @description: 根据学生编号查询学生信息
    */
    public User getUser(Integer id) {
        // 获取sqlSession
        try (SqlSession sqlSession = MyBatisSqlSessionFactory.getSqlSession()) {
            // 获取mapper代理对象调用方法
            return sqlSession.getMapper(UserMapper.class).getUserById(id);
        }
    }
}
